<?php

namespace app\modules\user\controllers;

use app\common\controllers\AccessController;
use app\modules\user\forms\info\StoreForm;
use app\modules\user\forms\info\UserForm;
use app\modules\user\services\InfoService;
use yii\base\UserException;

class InfoController extends AccessController {

    //获取信息
    public function actionGetInfo(){
        return InfoService::getInfoById();
    }

    //店铺
    public function actionStore(){
        $form = new StoreForm();
        if($form->load(\Yii::$app->getRequest()->post(),'') && InfoService::store($form)){
            return "";
        }else{
            throw new UserException(InfoService::getError());
        }
    }

    //用户
    public function actionUser(){
        $form = new UserForm();
        if($form->load(\Yii::$app->getRequest()->post(),'') && InfoService::user($form)){
            return "";
        }else{
            throw new UserException(InfoService::getError());
        }
    }
}